Apparently my professor's PDF is not fully correct. The real instruction is the the letters J,U,S,T,D,O,I,T is found in the users input string without having them in order. So here's my revised code. My last problem is that when the program sees a letter T it replaces both the 1st and last T's in the just_do_it array with space.
Code:
#include <ctype.h>
#include <stdio.h>
#include <string.h>
int
main(void)
{
char string[51], just_do_it[] = "JUSTDOIT";
fgets(string, 51, stdin);
for (int i = 0, end = strlen(string); i < end; i++)
string[i] = toupper(string[i]);
for (int i = 0, end = strlen(string), correct = 0; i < end; i++)
{
for (int j = 0; j < 8; j++)
{
if (string[i] == just_do_it[j] && just_do_it[j] != ' ' && string[i] != ' ')
{
correct++;
just_do_it[j] = ' ';
if (correct == 8)
{
printf("\nJust do it\n");
return 0;
}
}
}
}
printf("\nString not found\n");
return 0;
}
What I need is two T's instead of only one T
So:
Justdoi = FALSE
doTitsJU = TRUE